package com.cqjtu.store.admin.controller;

import com.cqjtu.store.admin.pojo.DTO.AdminLoginDTO;
import com.cqjtu.store.admin.pojo.VO.AdminLoginVO;
import com.cqjtu.store.admin.service.AdminService;
import com.cqjtu.store.common.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin")
@Slf4j
@Api(tags = "管理员模块")
public class AdminController {
@Autowired
    AdminService adminService;

    @PostMapping("login")
    @ApiOperation("管理员登录接口")
    public R<AdminLoginVO> login(@RequestBody @Validated AdminLoginDTO adminLoginDTO){
        log.debug("用户登录信息:{}",adminLoginDTO);
        AdminLoginVO adminLoginVO =  adminService.login(adminLoginDTO);
        System.out.println(adminLoginVO.toString());
        return R.ok(adminLoginVO);
    }
}
